# -*- coding: utf-8 -*-
#
# The Philatelist program is a fork of the OpenNumismat program
# Copyright (c) 2011 - 2024 Vitaly Ignatov (OpenNumismat) <opennumismat@gmail.com>
# Copyright (c) 2021 - 2024 Victor Nabatov (Philatelist) <nabatov.victor@gmail.com>
#

import os.path
import sys

import Philatelist

HOME_PATH = ''
IMAGES_PATH = ''
PRJ_PATH = ''
RESOURCES_PATH = ''
COLLECTIONS_PATH = ''
SLASH = '/'

def run():
    if sys.platform in ('win32', 'darwin'):
#        location = QStandardPaths.DocumentsLocation
        SLASH = '\\'
#    else:
#        location = QStandardPaths.HomeLocation
#        SLASH = '/'

    # Getting path where stored application data (icons, templates, etc)
    # sys.frozen is True when running from cx_Freeze/pyinstaller executable
    if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'):
        Philatelist.PRJ_PATH = sys._MEIPASS

    elif "__compiled__" in globals():  # for Nuitka
        Philatelist.PRJ_PATH = os.path.dirname(sys.executable)
    else:
        Philatelist.PRJ_PATH = os.path.abspath(os.path.dirname(__file__))

    # ~/Programs/Philatelist
    Philatelist.HOME_PATH = os.path.dirname(Philatelist.PRJ_PATH)
    # ~/Programs/Philatelist/Resources
    Philatelist.RESOURCES_PATH = os.path.join(Philatelist.HOME_PATH, 'Resources')
    # ~/Programs/Philatelist/Collections
    Philatelist.COLLECTIONS_PATH = os.path.join(Philatelist.HOME_PATH, 'Collections')
    # ~/Collections/Stamps
#    user_dirs = QStandardPaths.standardLocations(location)
#    Philatelist.IMAGES_PATH = os.path.join(user_dirs[0], "Collections/Stamps")
    # ~/Programs/Philatelist/Collections/Stamps
    Philatelist.IMAGES_PATH = os.path.join(Philatelist.COLLECTIONS_PATH, "Stamps")

    from Philatelist.main import main
    main()
